package dawn.service.async;

import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import dawn.service.Service;

public class AsyncService implements Service {
	private Queue<ICallback> callbacks = new ConcurrentLinkedQueue<ICallback>();

	// 异步调用的线程池
//	private ExecutorService excetor = Executors.newFixedThreadPool(1);

	@Override
	public void init() {
//		excetor.
	}

	@Override
	public void shutdown() {
		
	}
	
	@Override
	public void update() {
		while (callbacks.peek() != null) {
			ICallback callback = callbacks.poll();
			callback.callback();
		}
	}

	public void addCallback(ICallback callback) {
		callbacks.add(callback);
	}

	public ExecutorService getExcetor() {
//		return excetor;
		return null; // 此处待实现
	}
}
